package backend.project.gym_management.controller;

import backend.project.gym_management.service.HealthDataService;
import backend.project.gym_management.pojo.entity.HealthData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/api")
public class HealthDataController {

    @Autowired
    private HealthDataService healthDataService;

    @GetMapping("/healthData")
    public ResponseEntity<HealthData> getHealthData(@RequestParam Long uid) {
        HealthData healthData = healthDataService.getHealthDataByUid(uid);
        if (healthData != null) {
            return ResponseEntity.ok(healthData);
        } else {
            return ResponseEntity.notFound().build();
        }
    }
}

